package com.cqhfan.chatroom.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author 眭传洪
 * @create 2024-11-19 20:17
 */
@Getter
public enum ChatType {
    SINGLE(1, "单聊"),
    MULTI(2, "群聊")
    ;

    ChatType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @EnumValue
    @JsonValue
    final Integer value;

    final String desc;

    @JsonCreator
    public static ChatType fromValue(int value) {
        for (ChatType type : values()) {
            if (type.value == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }
}
